import { Table } from "antd";
import { useEffect, useState } from "react";
import { getOrderById } from "../../../../utils/sendRequst";
import { mapState } from "../pubData"; //订单状态的map格式数据
const OrderBox = (props) => {
  useEffect(() => {
    getOrderById({ id: props.id }).then((res) => {
      let arr = res.data.map((item) => {
        item.key = item.orderId;
        item.orStateName = mapState.get(item.orState);
        item.orEndTime == null
          ? (item.orEndTimeName = "未完成")
          : (item.orEndTimeName = item.orEndTime);

        return item;
      });
      setDataSource(arr);
    });
  }, []);
  let [dataSource, setDataSource] = useState([]);
  const columns = [
    {
      title: "订单编号",
      dataIndex: "orderId",
      key: "orderId",
    },
    {
      title: "订单状态",
      dataIndex: "orStateName",
      key: "orStateName",
    },
    {
      title: "订单金额",
      dataIndex: "orPrice",
      key: "orPrice",
    },
    {
      title: "下单时间",
      dataIndex: "orStartTime",
      key: "orStartTime",
    },
    {
      title: "完成时间",
      dataIndex: "orEndTimeName",
      key: "orEndTimeName",
    },
  ];
  return <Table dataSource={dataSource} columns={columns} pagination={false} />;
};
export default OrderBox;
